efform_onload = function ()
{	
//	var info = new EiInfo();
//	$('#ef_region_mainadd').hide();//隐藏明细区域
}; 

//上传 进度 标志 对象
var modalWin;
var uploadRowIndex=-1;
/*根据主表查询明细*/
efgrid_onRowClicked = function( grid_id, row_index ){ 
	if(grid_id == "ef_grid_result"){ 
//		$('#ef_region_mainadd').show();//显示明细区域
		var grid = efgrid.getGridObject(grid_id); 
		var selectedRow=grid.getRowData(row_index);
		for(var item in selectedRow){
			var colname=item;
			var colvalue=selectedRow[item];
			$('#ef_region_mainadd').find('#result_add-0-'+colname).val(colvalue);
		} 
		
	}
}


var ajax_callback = {
		onSuccess : function(eiInfo) {
			var grid = efgrid.getGridObject("ef_grid_result");
			grid.refresh(eiInfo);
		}, 
		onFail:function(eMsg)
		{
			alert("确认失败，原因："+eMsg);
		}

}	

button_insert_onclick = function (){
	var date1=$('#result_add-0-fdMeetingDate').val();
	var date2=$('#result_add-0-fdCreateDate').val();
	if (date1 > date2){
		EFAlert("会议日期晚于编制日期");
		return;
	}
	
	var ei_info=new EiInfo();
	ei_info.setByNodeObject(document.forms[0]); 
	if(ei_info.getBlock('result_add').getRows(0)[0][2].trim()==""){
		EFAlert("编制日期不能为空");
		return;
	}
	if(ei_info.getBlock('result_add').getRows(0)[0][3].trim()==""){
		EFAlert("会议日期不能为空");
		return;
	}
	if(ei_info.getBlock('result_add').getRows(0)[0][5].trim()==""){
		EFAlert("录入人不能为空");
		return;
	}
	if(ei_info.getBlock('result_add').getRows(0)[0][6].trim()==""){
		EFAlert("会议主题不能为空");
		return;
	}
	if(ei_info.getBlock('result_add').getRows(0)[0][7].trim()==""){
		EFAlert("会议内容不能为空");
		return;
	}
	
	var info = getDetail("ef_region_mainadd","result_add");
	if (null != info) {
		EiCommunicator.send("ZMCG60", "insert", info, ajax_callback);
	}
	window.location.reload(); 
}

button_update_onclick = function (){	
	var date1=$('#result_add-0-fdMeetingDate').val();
	var date2=$('#result_add-0-fdCreateDate').val();
	if (date1 > date2){
		EFAlert("会议日期晚于编制日期");
		return;
	}
	
	var ei_info=new EiInfo();
	ei_info.setByNodeObject(document.forms[0]); 
	if(ei_info.getBlock('result_add').getRows(0)[0][2].trim()==""){
		EFAlert("编制日期不能为空");
		return;
	}
	if(ei_info.getBlock('result_add').getRows(0)[0][3].trim()==""){
		EFAlert("会议日期不能为空");
		return;
	}
	if(ei_info.getBlock('result_add').getRows(0)[0][5].trim()==""){
		EFAlert("录入人不能为空");
		return;
	}
	if(ei_info.getBlock('result_add').getRows(0)[0][6].trim()==""){
		EFAlert("会议主题不能为空");
		return;
	}
	if(ei_info.getBlock('result_add').getRows(0)[0][7].trim()==""){
		EFAlert("会议内容不能为空");
		return;
	}
	
	var info = getDetail("ef_region_mainadd","result_add");	
	if (null != info) {	
		var fdStatus; 
		fdStatus = $('#result_add-0-fdStatus').val();
		if(fdStatus == "1")
			{
			alert("只能修改未生效的记录");return;
			}
		EiCommunicator.send("ZMCG60", "update", info, ajax_callback);
	} 
	window.location.reload(); 
}


button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_result", "ZM","ZMCG60","query");
}

button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="0")
		{
			EFAlert("只能对未生效的记录进行删除！"); return;
		}
	}
	        EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM","ZMCG60","delete",true);
	}); 
}

button_report_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="0")
		{
			EFAlert("只能对未生效的记录进行操作！"); return;
		}
	}
		efgrid.submitForm( "ef_grid_result", "ZM","ZMCG60","report",true); 
}
/**----------------------------从这里往下的方法都是附件操作相关方法------------------
 */
button_upload_onclick=function(){
	var grid = efgrid.getGridObject("ef_grid_result");
	var row_index=grid.getCurrentRowIndex();
	if(row_index<0){
		EFAlert("请先点击一下选中项目信息后上传！");
		return;
	}
	var docId=grid.getCellValueByColumnName(row_index,"fdDocId");
	if(!isAvailable(docId)) {
		EFAlert("未指定文档号！", "系统警告");
		return false;
	}
	var url = "DispatchAction.do?efFormEname=EUAF3501";
		url = url + "&inqu_status-0-code=zm.cg";
	
	if(grid.getCellValueByColumnName(row_index,"fdStatus")!="0")
	{
		url = url + "&editFlag=0";
	}else{
		url = url + "&editFlag=1";
	}
	url = url + "&inqu_status-0-docId="+docId+"&time=" + new Date().getTime();
	
	EFColorbox({href:url,title:"附件管理",width:"80%", height:"80%", iframe:true});
}  